package DimensionGui;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TextAreaActionListener implements ActionListener {

	/**
	 * Used for pressing enter button to see immediate results
	 * 
	 * 
	 */
	TextField _parentTextField;

	TextAreaActionListener(TextField heightTextField) {
		/**
		 * Needs this constructor to find parent and ultimately edit the shapes
		 * dimensions
		 * 
		 */

		_parentTextField = heightTextField;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub

		System.out.println(_parentTextField.getText());
		
		// set value to what was typed in
		int i =Integer.parseInt(_parentTextField.getText());
		if(_parentTextField instanceof MyTextAreaWidth){
			((MyTextAreaWidth) _parentTextField).setDimension(i);
		}
		if (_parentTextField instanceof MyTextAreaHeight){
				((MyTextAreaHeight) _parentTextField).setDimension(i);
			}
			
		}
		

	}



